package cn.learn.base;

import cn.learn.domain.system.user.User;
import org.springframework.web.bind.annotation.ModelAttribute;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BaseController {

    public HttpServletRequest request;
    public HttpServletResponse response;
    public HttpSession session;

    // 模拟企业ID表示与企业名
    public String companyId;
    public String companyName;
    public User user;

    @ModelAttribute
    public void init(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        this.request = request;
        this.response = response;
        this.session = session;
        // 获取当前登陆用户
        User user=(User)session.getAttribute("user");
        if(user!=null){
            this.companyId=user.getCompanyId();
            this.companyName=user.getCompanyName();
        }
        this.user = user;
    }

}
